set number "行号
set relativenumber "相对行号
set expandtab "设置缩进
set tabstop=4 "两个空格的缩进
set shiftwidth=4
set softtabstop=4
set ignorecase
set smartcase
set notimeout "关闭命令输入的等待超时
"set mouse=a
"set paste
set jumpoptions=stack "栈的跳转方式

let mapleader="\<SPACE>" " defualt ,




if empty(glob('~/.config/nvim/autoload/plug.vim'))
  :exe '!curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
        \ https://gitee.com/fj-awei/vim-plug/raw/master/plug.vim'
  au VimEnter * PlugInstall --sync | source $MYVIMRC
endif



" =======================
" ===  plugins  begin ===
" =======================
call plug#begin('~/.config/nvim/plugged')
  " file explorer
 "Plug 'preservim/nerdtree'
 " Plug 'fj-awei/nerdtree' "https://gitee.com/fj-awei/nerdtree.git

  " highlight
  Plug 'cateduo/vsdark.nvim'
  "Plug 'yaojinmin/vsdark.nvim'
  Plug 'jackguo380/vim-lsp-cxx-highlight'
  "Plug 'zgpio/vim-lsp-cxx-highlight' "根据语义进行的插件，好像是跟coc 一起使用的 //根据语言服务器提供的信息，给出自定义函数的高亮

  " file finder
  "Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' }
 " Plug 'HyperChao/LeaderF', { 'do': ':LeaderfInstallCExtension' }

  " lsp
  "Plug 'neocl
  "coc.nvim', {'branch': 'release'}
  Plug 'neoclide/coc.nvim', {'branch': 'release'}
 " Plug 'ovoll/coc.nvim', {'branch': 'release'}
  

  "================================
  "========= add ===============
  "=================================

  "	关键字高亮
	Plug 'lfv89/vim-interestingwords'  
"	Plug 'jxsylar/vim-interestingwords'  

  Plug 'ctrlpvim/ctrlp.vim'
  "Plug 'myqcyz/ctrlp.vim'

  Plug 'tacahiroy/ctrlp-funky' 
  "Plug 'tbq2616/ctrlp-funky' 
  
 Plug 'easymotion/vim-easymotion' 
  "Plug 'zhengqijun/vim-easymotion' 

  Plug 'mbbill/undotree'
  "Plug 'wenjinwr/undotree'



  Plug 'kyazdani42/nvim-web-devicons' " Recommended (for coloured icons)
  "Plug 'zhengqijun/nvim-web-devicons' " Recommended (for coloured icons)
  " Plug 'ryanoasis/vim-devicons' Icons without colours
   Plug 'akinsho/bufferline.nvim', { 'tag': 'v2.*' }
  " Plug 'HeLiangMsg/vim-bufferline', { 'tag': 'v2.*' }

  Plug 'kyazdani42/nvim-tree.lua'


  Plug 'numToStr/Comment.nvim'
  Plug 'feline-nvim/feline.nvim'



  Plug 'windwp/nvim-autopairs'

  " Plug 'nvim-lua/plenary.nvim'
  " Plug 'filipdutescu/renamer.nvim', { 'branch': 'master' }

  Plug 'akinsho/toggleterm.nvim', {'tag' : 'v2.*'}


  Plug 'lukas-reineke/indent-blankline.nvim'
call plug#end()


" =================================
" ===   plugins  configuration  ===
" =================================

" ==== preservim/nerdtree ====

nnoremap <LEADER>e :NvimTreeFindFile<CR>



" ==== cateduo/vsdark.nvim ====

set termguicolors
let g:vsdark_style = "dark"
colorscheme vsdark




" ==== neoclide/coc.nvim ====
" ==== ckguo380/vim-lsp-cxx-highlight ====

hi default link LspCxxHlSymFunction cxxFunction
hi default link LspCxxHlSymFunctionParameter cxxParameter
hi default link LspCxxHlSymFileVariableStatic cxxFileVariableStatic
hi default link LspCxxHlSymStruct cxxStruct
hi default link LspCxxHlSymStructField cxxStructField
hi default link LspCxxHlSymFileTypeAlias cxxTypeAlias
hi default link LspCxxHlSymClassField cxxStructField
hi default link LspCxxHlSymEnum cxxEnum
hi default link LspCxxHlSymVariableExtern cxxFileVariableStatic
hi default link LspCxxHlSymVariable cxxVariable
hi default link LspCxxHlSymMacro cxxMacro
hi default link LspCxxHlSymEnumMember cxxEnumMember
hi default link LspCxxHlSymParameter cxxParameter
hi default link LspCxxHlSymClass cxxTypeAlias

" coc extensions
" 每一个扩展都需要一个后端服务去支持
let g:coc_global_extensions = [
      \ 'coc-json',
      \ 'coc-tsserver',
      \ 'coc-css',
      \ 'coc-html',
      \ 'coc-vimlsp',
      \ 'coc-cmake',
      \ 'coc-highlight',
      \ 'coc-pyright'
      \ ]

set signcolumn=number
" <TAB> to select candidate forward or
" pump completion candidate
inoremap <silent><expr> <TAB>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
" <s-TAB> to select candidate backward
inoremap <expr><s-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
  let col = col('.')-1
  return !col || getline('.')[col - 1] =~# '\s'
endfunction

" <CR> to comfirm selected candidate
" only when there's selected complete item
if exists('*complete_info')
  inoremap <silent><expr> <CR> complete_info(['selected'])['selected'] != -1 ? "\<C-y>" : "\<C-g>u\<CR>"
endif

" 查看关键字对应的帮助文档
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
  if(index(['vim', 'help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  elseif (coc#rpc#ready())
    call CocActionAsync('doHover')
  else
    execute '!' . &keywordprg . " " . expand('<cword>')
  endif
endfunction

" highlight link CocHighlightText Visual
" autocmd CursorHold * silent call CocActionAsync('highlight')   " TODO

"重命名
nmap <leader>rn <Plug>(coc-rename) 
xmap <leader>f <Plug>(coc-format-selected)
command! -nargs=0 Format :call CocAction('format')

augroup mygroup
  autocmd!
  autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
  autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end

"错误提示信息跳转
" diagnostic info
nnoremap <silent><nowait> <LEADER>d :CocList diagnostics<CR>
nmap <silent> <LEADER>- <Plug>(coc-diagnostic-prev)
nmap <silent> <LEADER>= <Plug>(coc-diagnostic-next)
nmap <LEADER>qf <Plug>(coc-fix-current)

" Remap <C-f> and <C-b> for scroll float windows/popups.
if has('nvim-0.4.0') || has('patch-8.2.0750')
  nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
  inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<C-r>=coc#float#scroll(1)\<CR>" : "\<Right>"
  inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<C-r>=coc#float#scroll(0)\<CR>" : "\<Left>"
  vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>"
  vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>"
endif


" Use <c-space> to trigger completion.
if has('nvim')
  inoremap <silent><expr> <c-space> coc#refresh()
else
  inoremap <silent><expr> <c-@> coc#refresh()
endif

" statusline support
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}  "TODO

" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gD :tab sp<CR><Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)

function! s:generate_compile_commands()
  if empty(glob('CMakeLists.txt'))
    echo "Can't find CMakeLists.txt"
    return
  endif
  if empty(glob('.vscode'))
    execute 'silent !mkdir .vscode'
  endif
  execute '!cmake -DCMAKE_BUILD_TYPE=debug
      \ -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -S . -B .vscode'
endfunction
command! -nargs=0 Gcmake :call s:generate_compile_commands()

" In your init.lua or init.vim
set termguicolors
lua << EOF
require("bufferline").setup{
    options = {
      buffer_close_icon = '',
      modified_icon = '',
      close_icon = '',
      left_trunc_marker = '',
      right_trunc_marker = '',
      max_name_length = 14,
      max_prefix_length = 13,
      tab_size = 20,
      diagnostics = false,
      offsets = { { filetype = 'NvimTree', text = '', padding = 1 } },
      show_buffer_icons = true,
      show_buffer_close_icons = true,
      show_close_icon = true,
      show_tab_indicators = true,
      persist_buffer_sort = true,
      separator_style = 'thin',
      enforce_regular_tabs = true,
      always_show_bufferline = true,
    },
 
}
EOF



 " Use local vimrc if available {
     if filereadable(expand("~/.config/nvim/expansion.vim"))
         source ~/.config/nvim/expansion.vim
     endif
 " }




lua << EOF
require('Comment').setup()
require('feline').setup()
---require("nvim-tree").setup()
require("nvim-tree").setup({
  sort_by = "case_sensitive",
  view = {
    adaptive_size = true,
    mappings = {
      list = {
        { key = "u", action = "dir_up" },
        { key = "d", action = "dir_down" },
      },
    },
  },
  renderer = {
    group_empty = true,
  },
  filters = {
    dotfiles = true,
  },
})

---nvim-web-devicons
require'nvim-web-devicons'.setup {
 -- your personnal icons can go here (to override)
 -- you can specify color or cterm_color instead of specifying both of them
 -- DevIcon will be appended to `name`
 override = {
  zsh = {
    icon = "",
    color = "#428850",
    cterm_color = "65",
    name = "Zsh"
  }
 };
 -- globally enable default icons (default to false)
 -- will get overriden by `get_icons` option
 default = true;
}


--autopairs 
require("nvim-autopairs").setup {}


--toggleterm
require("toggleterm").setup{}



--indent_blankline
vim.opt.list = true
vim.opt.listchars:append("eol:↴")

require("indent_blankline").setup {
    show_end_of_line = true,
}




EOF



